package com.ym.script.util;

import android.view.View;
import android.view.ViewGroup;

public class ViewUtil {

	public static String getText(View view) {
		StringBuffer result = new StringBuffer();
		try {
			String tv = (String) view.getClass().getMethod("getText")
					.invoke(view);
			if (tv != null)
				result.append(tv);
		} catch (Exception e) {
		}
		if (view instanceof ViewGroup) {
			int count = ((ViewGroup) view).getChildCount();
			for (int i = 0; i < count; i++) {
				View child = ((ViewGroup) view).getChildAt(i);
				String text = getText(child);
				if (text != null)
					result.append(text);
			}
		}
		return result.toString();
	}
}
